﻿// Study0703.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
// 第七章 继承 类型兼容规则

#include <iostream>
using namespace std;

class Base1
{
public:
	void display()
	{
		cout << "Base1输出" << endl;
	}
};
class Base2:public Base1
{
public:
	void display()
	{
		cout << "Base2输出" << endl;
	}
};
class Derived :public Base2
{
public:
	void display()
	{
		cout << "Derived输出" << endl;
	}
};
void func(Base1* ptr)
{
	ptr->display();
}
int main()
{
	Base1 base1;
	Base2 base2;
	Derived derived;
	func(&base1);
	func(&base2);
	func(&derived);
	return 0;
}


